package com.muh.task;

import com.muh.util.RabbitMQUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.MessageProperties;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class NewTask {

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection connection = RabbitMQUtil.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(RabbitMQUtil.QUEUE_WORK, true, false, false, null);
        for (int i = 0; i < 5; i++) {
            String message = "Hello World, task"+i;
            channel.basicPublish("", RabbitMQUtil.QUEUE_WORK, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes());
        }
        channel.close();
        connection.close();
    }
}
